from django.urls import path, include
from rest_framework.routers import DefaultRouter
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView, TokenVerifyView
from . import views
from django.views.generic import TemplateView

app_name = 'account'  # 定义应用命名空间

router = DefaultRouter()
router.register(r'users', views.UserViewSet, basename='user')  # 用户管理:增删改

urlpatterns = [
    path('', include(router.urls)),

    path('auth/login/', views.CustomLoginView.as_view(), name='auth_login'),
    path('auth/loginView/', views.LoginView.as_view(), name='view_login'),
    path('auth/sms_send_code/', views.SendSmsCode.as_view(), name='send_sms_code'),  # 获取短信验证码
    path('auth/sms_verify_code/', views.VerifySmsCode.as_view(), name='verify_sms_code'),  # 短信验证码登录
    path('auth/refresh/', TokenRefreshView.as_view(), name='auth_refresh'),

    path('password/reset/', views.PasswordResetView.as_view(), name='password-reset'),
    path('send_sms/', views.SendSMSView.as_view(), name='send-sms'),

    # 组权分配
    path('rbac/group_perm/manage/', views.groupPermManage, name='group_perm_manage'),
    # 组名保存
    path('rbac/group_name/manage/', views.groupNameManage, name='group_name_manage'),
    # 组名删除
    path('rbac/group_delete/manage/<int:group_id>/', views.groupDeleteManage, name='group_delete_manage'),
    # 组关联的权限:更新或者新增
    path('rbac/groups/<int:group_id>/permissions/', views.update_group_permissions, name='update_group_permissions'),

    # 用户管理
    path('rbac/user/manage/', views.UserManageView.as_view(), name='user-manage'),
    # 权限管理
    path('rbac/permission/', views.rbac_manager, name='user_group_manage'),
    # 权限配置保存
    path('rbac/save_user_permissions/', views.SaveUserPermissionsView.as_view(),name='save_user_permissions'),


    # path('rbac/search/', views.rbac_search, name='rbac_search'),
    # path('rbac/update-permissions/', views.update_permissions, name='update_permissions'),

]

